# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Pig Monkey <pm@pig-monkey.com>
# Contributor: Caltlgin Stsodaat <contact@fossdaily.xyz>
# Contributor: Javier Tiá <javier dot tia at gmail dot com>

pkgname=visidata
pkgver=2.11.1
pkgrel=1
pkgdesc='Terminal spreadsheet multitool for discovering and arranging data'
arch=(any)
url="https://www.$pkgname.org"
_url="https://github.com/saulpw/$pkgname"
license=(GPL3)
depends=(python
         python-dateutil
         python-importlib-metadata
         python-setuptools)
optdepends=('python-dnslib: pcap support'
            'python-fonttools: ttf/otf support'
            'python-h5py: hdf5 support'
            'python-lxml: html/xml support'
            'python-openpyxl: xlsx support'
            'python-pandas: dta (Stata) support'
            'python-pdfminer: pdf support'
            'python-psycopg2: postgres support'
            'python-pyaml: yaml/yml support'
            'python-pyarrow: parquet support'
            'python-pypng: png support'
            'python-requests: http support'
            'python-tabulate: tabulate saver support'
            'python-urllib3: remote zip support'
            'python-vobject: vcf support'
            'python-wcwidth: tabulate saver with unicode support'
            'python-xlrd: xls support')
# optdepends+=( # AUR only optdepends
#             'python-dpkt: pcap support'
#             'python-mapbox-vector-tile: mbtiles support'
#             'python-namestand: graphviz support'
#             'python-pyshp: shapefiles support')
makedepends=(python-{build,installer,wheel})
checkdepends=(python-pytest)
_archive="$pkgname-$pkgver"
# pypi sources don’t have scripts to generate completions
# source=("https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$_archive.tar.gz")
source=("$_url/archive/v$pkgver/$_archive.tar.gz")
sha256sums=('8d4f3f7453c1914a40eb00edc4196db0b88819d9d4d1ae3a22f603f8b7d5126d')

build() {
	cd "$_archive"
	python -m build -wn
	./dev/zsh-completion.py
}

check() {
	cd "$_archive"
	# Testing commands assumes reading an rc file not present in chroot build env
	pytest -k 'not test_baseCommands'
}

package() {
	cd "$_archive"
	python -m installer -d "$pkgdir" dist/*.whl
	install -Dm0644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
	install -Dm0644 -t "$pkgdir/usr/share/zsh/site-functions" "_$pkgname"
}
